<template>
  <div class="dialog">
    <el-dialog
      title="预览全部设备及保养项表"
      :visible.sync="showDialog"
      width="50%"
      top="0"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <el-table
        ref="tableData"
        class="tableData"
        highlight-current-row
        :data="tableData"
        stripe
        border
      >
        <el-table-column type="index" label="序号" width="50">
          <template
            slot-scope="scoped"
          >{{ scoped.row.checkItemModelId?scoped.$index+1:'' }}</template>
        </el-table-column>
        <el-table-column prop="equipmentName" label="设备名称" />
        <el-table-column prop="checkItemName" label="保养项名称" />
        <el-table-column label="标准值">
          <template slot-scope="scoped">
            <div
              v-if="scoped.row.checkType==='NUMTYPE'"
            >{{ scoped.row.lowerLimit?'下限:'+scoped.row.lowerLimit+scoped.row.unitName:'' }}{{ scoped.row.upperLimit?'上限:'+scoped.row.upperLimit+scoped.row.unitName:'' }}</div>
            <div v-else>{{ scoped.row.standardValue }}</div>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelbtn" @click="cancel()">取 消</el-button>
        <!-- <el-button type="primary" class="savebtn" @click="save('ruleForm')">保 存</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    showCheckList: {
      type: [Array],
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      showDialog: this.show,
      tableData: [],
    };
  },

  watch: {
    show(v) {
      this.showDialog = v;
    },
    showCheckList(v) {
      this.tableData = [];
      v.forEach((a) => {
        if (a.planTaskCheckItemMapperList) {
          a.planTaskCheckItemMapperList.forEach((b) => {
            b.equipmentCode = a.equipmentCode;
            b.equipmentName = a.equipmentName;
            this.tableData.push(b);
          });
        }
      });
    },
  },
  created() {},
  mounted() {},
  methods: {
    close() {
      this.$emit("closeDialog");
    },
    cancel() {
      this.$emit("cancelDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  height: 500px;
}
::v-deep .el-table th {
  color: #000;
  background-color: rgba(120, 182, 193, 0.4) !important;
}
::v-deep .el-table .el-table__row--striped {
  color: #000;
  background-color: rgba(186, 186, 186, 0.4) !important;
}
::v-deep.el-table td,
.el-table th.is-leaf,
.el-table--border,
.el-table--group,
.el-table th.is-leaf {
  border-color: #d3d3d3 !important;
}
::v-deep .el-table th.is-leaf {
  border-color: #d3d3d3 !important;
}
::v-deep .el-table__empty-text {
  color: #000;
}
::v-deep .el-table {
  color: #000;
  position: relative !important;
}
</style>
